//
//  DemoSet.swift
//  swiftDemo
//
//  Created by JIENING ZHANG on 2020/1/8.
//  Copyright © 2020 lovivid. All rights reserved.
//

import UIKit

class DemoSet: NSObject {
    class func demoLogic() {
        let monthDic : [String : Int] = [
            "January" :     31,
            "February" :    28,
            "March" :       31,
            "April" :       30,
            "May" :         31,
            "June" :        30,
            "July" :        31,
            "August" :      31,
            "September" :   30,
            "October" :     31,
            "November" :    30,
            "December" :    31,
        ];
        
        let nameSet = Set(monthDic.keys)
        var loop = 0
        for name in nameSet {
            print("nameSet, \(loop) --> \(name)")
            loop += 1
        }
        
        var valueSet = Set(monthDic.values)
        loop = 0
        for val in valueSet {
            print("valueSet, \(loop) --> \(val)")
            loop += 1
        }
        
        valueSet.insert(29);
        print("after add 29 into set, valueSet = \(valueSet)")
        
        if valueSet.contains(28) {
            print("valueSet.contains(28) true")
        }
        valueSet.remove(28)
        
        if !(valueSet.contains(28)) {
            print("valueSet.contains(28) false")
        }
/*
输出:
         
nameSet, 0 --> November
nameSet, 1 --> February
nameSet, 2 --> July
nameSet, 3 --> October
nameSet, 4 --> April
nameSet, 5 --> August
nameSet, 6 --> May
nameSet, 7 --> June
nameSet, 8 --> January
nameSet, 9 --> September
nameSet, 10 --> December
nameSet, 11 --> March
valueSet, 0 --> 28
valueSet, 1 --> 31
valueSet, 2 --> 30
after add 29 into set, valueSet = [28, 31, 30, 29]
valueSet.contains(28) true
valueSet.contains(28) false
*/
    }
}
